#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : Leiyh
# @File : Industrial_park_was_visited.py


from time import sleep
from selenium.webdriver.common.keys import Keys
import datetime
from base.ui.base_ui import BaseUI


# 产业园获客模块
class Industrial_park_was_visited(BaseUI):
    # 左上角银行数字化中心logo
    p_logo = "//div[contains(text(),'银行数字化中心')]"
    # 产业园获客
    p_ipwv = "//p[contains(text(),'产业园获客')]"
    # 省份
    p_province = '//span[@class="el-link--inner"]'
    p_province_beijing = "//li[contains(text(),'北京市 ')]"
    # 选择行业
    p_industry_selection = '//input[@placeholder="请选择行业"]'
    # 搜索园区名称
    p_Name_of_park = '//input[@placeholder="请输入园区名称"]'
    # 园区名称
    p_industry_classify = "//a[contains(text(),'中关村')]"
    # 成立年份:开始日期
    p_start_date = '//input[@class="el-range-input" and @placeholder="开始日期"]'
    year = datetime.date.today().year
    p_start_date_1 = "//a[contains(text(),'{}')]".format(year)
    # 区域下拉值
    # p_region_value = "//span[contains(text(),'北京市')]"
    # # 产业
    # p_industry = "//span[contains(text(),'支柱产业')]"
    # # 企业
    # p_company = '((//div[@class="topic-industry-list common-panel"]/div)[1]/div/div/div)[1]'
    # # 产业图谱>查看完整产业链
    # p_industry_map = "//a[contains(text(),'查看完整产业链')]"
    # # 产业下拉框
    # p_industry_1 = "(//label[contains(text(),'产业：')]/../div/div/div)[1]/input"
    # # p_industry_2 = '((//div[@class="el-scrollbar"]/div)[1]/ul/li)[1]'
    # p_industry_2 = "(//span[contains(text(),'软件和信息技术服务业')])[last()]"
    # # 软件和信息技术服务业>消费电子产品>查看更多
    # selector_consumer_electronic = '#csf_20119210 > rect:nth-child(3)'
    # p_see_more = "//span[contains(text(),'查看更多')]"
    # # 上市市场筛选
    # p_Listing_market_screening_1 = '(//div[@class="el-input el-input--mini el-input--suffix"])[1]/input'
    # p_Listing_market_screening_2 = '((//ul[@class="el-scrollbar__view el-select-dropdown__list"])[last()]/li)[5]'
    # # 融资轮次筛选
    # p_Financing_round_screening_1 = '(//div[@class="el-input el-input--mini el-input--suffix"])[1]/input'
    # p_Financing_round_screening_2 = '((//ul[@class="el-scrollbar__view el-select-dropdown__list"])[last()]/li)[last()-3]'
    # # 企业资质筛选
    # p_Enterprise_qualification_screening_1 = '(//div[@class="el-input el-input--mini el-input--suffix"])[2]/input'
    # p_Enterprise_qualification_screening_2 = '((//ul[@class="el-scrollbar__view el-select-dropdown__list"])[last()]/li)[last()]'
    # # 查询
    # p_query = "//span[contains(text(),'查询')]"
    # # 产业园统计>查看更多产业园
    # p_Industrial_Park_Statistics = "//a[contains(text(),'查看更多产业园')]"
    # # 行业动态资讯>新闻线索
    # p_news_clue = "//span[contains(text(),'新闻线索')]"
    # # 行业动态资讯>政策线索
    # p_clues_policy = "//span[contains(text(),'政策线索')]"
    # # 行业动态资讯>查看更多线索
    # p_check_out_more_clues = "//a[contains(text(),'查看更多线索')]"
    # # 推荐企业>筛选更多企业
    # p_screening_more_enterprises = "//a[contains(text(),'筛选更多企业')]"
    # # 推荐企业>企业详情
    # p_company_details = '((//div[@class="common-data-list--body"]/div)[1]/div)[1]'

    # 点击左上角银行数字化中心logo
    def click_logo(self):
        self.click(self.p_logo)

    # 点击产业园获客
    def click_ipwv(self):
        self.click(self.p_ipwv)

    # 左上角选择指定的省份
    def click_province(self):
        self.click(self.p_province)
        self.click(self.p_province_beijing)

    # 搜索指定园区名称
    def click_region(self):
        self.send_keys(self.p_Name_of_park,"中关村")
        self.click(self.p_province)
        self.click(self.p_industry_classify)
#
#     # 企业列表
    def Bloggers(self):
        self.click(self.p_start_date)
        self.click(self.p_start_date_1)
        self.click(self.p_start_date_1)

#
#     # 选择左侧企业
#     def click_company(self):
#         self.click(self.p_company)
#
#     # 查看完整产业链
#     def click_industry_map(self):
#         self.click(self.p_industry_map)
#
#     # 选择产业
#     def click_industry_1(self):
#         self.click(self.p_industry_1)
#         self.click(self.p_industry_2)
#
#     # 查看更多相关公司
#     def click_see_more(self):
#         sleep(1)
#         # 根据指定的selector鼠标悬浮,点击更多
#         self.move_to_element_selector(self.selector_consumer_electronic)
#         self.click(self.p_see_more)
#         # 搜索相关公司
#         self.click(self.p_Listing_market_screening_1)
#         self.click(self.p_Listing_market_screening_2)
#
#         self.click(self.p_Financing_round_screening_1)
#         self.click(self.p_Financing_round_screening_2)
#
#         self.click(self.p_Enterprise_qualification_screening_1)
#         self.click(self.p_Enterprise_qualification_screening_2)
#
#         self.click(self.p_query)
#
#     # 查看更多产业园
#     def click_Industrial_Park_Statistics(self):
#         self.click(self.p_Industrial_Park_Statistics)
#
#     # 查看新闻线索
#     def click_news_clue(self):
#         self.click(self.p_news_clue)
#
#     # 查看政策线索
#     def click_clues_policy(self):
#         self.click(self.p_clues_policy)
#
#     # 查看更多线索
#     def click_check_out_more_clues(self):
#         self.click(self.p_check_out_more_clues)
#
#     # 筛选更多企业
#     def click_screening_more_enterprises(self):
#         self.click(self.p_screening_more_enterprises)
#
#     # 企业详情
#     def click_company_details(self):
#         self.click(self.p_company_details)
#
#
# 产业园获客
def ipwv():
    ipwv = Industrial_park_was_visited()
    ipwv.click_logo()
    ipwv.click_ipwv()
    ipwv.click_province()
    # 点击查看完整产业链
    ipwv.click_region()
    # 切换至完整产业链页面
    ipwv.switch_to_windows_by_index(1)
    assert True == ipwv.wait_util_text("//span[contains(text(),'中关村')]", "中关村")
    # 断言企业总数量不能为0
    park_count  = ipwv.get_texts('//span[@class="park-stat-name"]/following-sibling::span')
    assert '0' not in park_count
    sleep(1)
    # 企业列表
    # 断言企业列表数据是否为空
    assert False == ipwv.is_element_exist("(//p[contains(text(),'暂无数据')])[6]")
    # 点击选择成立年份
    ipwv.Bloggers()
    sleep(1)
    # todo 还需要做资质 行业 导出企业 的功能测试
